package edu.siu.math.egut.drivers;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import edu.siu.math.egut.io.Algorithms;
/**
 * Driver for experimenting with IO.
 * 
 * @author josephhundley
 *
 */

public class IODriver {

 
    /**
     * Entry point.
     * 
     * @param args These are ignored.
     */
    public static void main(String[] args) {
	
	Scanner scanner = new Scanner( System.in );
	System.out.print("Enter a filename.");
	String fileName = scanner.nextLine();
	// 
	String s;
	try {
	    s = Algorithms.fileToString(fileName);
	} catch (FileNotFoundException e) {
	    System.out.print("File not found.");
	    System.exit(1);
	    s="[[1]]";  // to ensure that s is always initialized before its use later... though this 
	    // line would never be read...
	}
	int[][] m=new int[1][1];
	try {
	    m = Algorithms.readLiEMatrix(s);
	} catch (Exception e) {
	    e.printStackTrace();
	}

	int numRows = m.length;
	int numCols =m[0].length;
	System.out.println("m");
	System.out.println(numRows);
	System.out.println(numCols);
	for( int i = 0; i < numRows; i++){
	    for( int j = 0 ; j < numCols ; j++){
		System.out.print(m[i][j]);
	    }
	    System.out.println();
	}

    }// end main

}// end Class
